package com.ocom.human.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocom.common.entity.master.EntityWechatAppInfo;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.common.enums.MasterSlaveEnum;
import com.ocom.human.dao.IDaoWechatAppInfo;
import com.ocom.human.service.WechatAppInfoService;
import com.ocom.mysql.aspect.DataSourceAspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class WechatAppInfoServiceImpl extends ServiceImpl<IDaoWechatAppInfo, EntityWechatAppInfo> implements WechatAppInfoService {

    @Autowired
    private IDaoWechatAppInfo daoWechatAppInfo;

    @DataSourceAspect(type= DataSourceEnum.MAIN_DB,isMaster = MasterSlaveEnum.SLAVE)
    @Override
    public EntityWechatAppInfo getAppOcom2Info(String appName) {
        //查找app_name=”ocom2.0”的appid值
        QueryWrapper<EntityWechatAppInfo> query = Wrappers.query();
        query.eq("app_name",appName);
        query.last("limit 1");
        return daoWechatAppInfo.selectOne(query);
    }
}
